﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Noris.Schedule.Support;
using Noris.Schedule.Support.Services;

using Noris.Schedule.Planning.ProcessData;
using Noris.Schedule.Planning.DataFace;
using System.Drawing;

namespace Noris.Schedule.Planning.Services
{
	// Tento soubor obsahuje deklarace grafů pro plánovací tabuli výroby.
	// Popis deklaranta je uveden v remarks u interface IGraphDeclarator.
	internal class GraphDeclaratorManufacturing : IGraphDeclarator
	{
		/// <summary>
		/// V této metodě konkrétní služba deklaruje svoje grafy, které chce zobrazovat, včetně jejich parametrů.
		/// </summary>
		/// <param name="args"></param>
		void IGraphDeclarator.GraphDeclare(GraphDeclareArgs args)
		{
			object tag = Noris.Schedule.Planning.ProcessData.Constants.PlanningGraphTag;
			IDataSource dataSource = new MfrPlanningConnectorCls(PlanningParametersCls.DefaultForRun);
			GraphDeclarationCls gd;

			// Graf využití kapacit:
			gd = new GraphDeclarationCls(RowGraphMode.CapacityUtilization, PlanUnitCCls.ClassNr, dataSource, tag,
				"Stavy kapacit", GraphPositionType.FullPage);
			gd.DrawLinkMode = LinkElementDrawMode.NoDraw;
			gd.TargetGraphActivityOnDataChanged = TargetGraphCrossActivityMode.Anywhere;
			gd.TargetGraphActivityOnClick = TargetGraphCrossActivityMode.None;
			gd.TargetGraphActivityOnDoubleClick = TargetGraphCrossActivityMode.OnOtherPage;
			gd.CurrentGraphActivityOnDataChanged = CurrentGraphCrossActivityMode.DefaultEdit;
			gd.CurrentGraphActivityOnClick = CurrentGraphCrossActivityMode.None;
			gd.CurrentGraphActivityOnDoubleClick = CurrentGraphCrossActivityMode.FindEqualRow | CurrentGraphCrossActivityMode.ActivateFirstEqualRow | CurrentGraphCrossActivityMode.ActivateGraphPage | CurrentGraphCrossActivityMode.StopProcess;
			gd.CurrentGraphCallDataSourceOnActivate = true;
			gd.CurrentGraphCallDataSourceOnDeactivate = true;
			args.GraphDeclarationList.Add(gd);

			// Graf stavů kapacit a tasků, které v nich jsou:
			gd = new GraphDeclarationCls(RowGraphMode.TaskCapacityLink, PlanUnitCCls.ClassNr, dataSource, tag, 
				"Kapacitní úkoly", GraphPositionType.TopPart);
			gd.DrawLinkMode = LinkElementDrawMode.HighlightActiveLink;
			gd.TargetGraphActivityOnDataChanged = TargetGraphCrossActivityMode.Anywhere;
			gd.TargetGraphActivityOnClick = TargetGraphCrossActivityMode.OnThisPage;
			gd.TargetGraphActivityOnDoubleClick = TargetGraphCrossActivityMode.OnOtherPage;
			gd.CurrentGraphActivityOnRowEnter = CurrentGraphCrossActivityMode.InactiveWhenInvisible | CurrentGraphCrossActivityMode.FindByDataSource | CurrentGraphCrossActivityMode.SelectElements | CurrentGraphCrossActivityMode.ActivateFirstEqualRow | CurrentGraphCrossActivityMode.StopProcess;
			gd.CurrentGraphActivityOnDataChanged = CurrentGraphCrossActivityMode.DefaultEdit;
			gd.CurrentGraphActivityOnClick = CurrentGraphCrossActivityMode.InactiveWhenInvisible | CurrentGraphCrossActivityMode.FindByDataSource | CurrentGraphCrossActivityMode.SelectElements | CurrentGraphCrossActivityMode.ActivateFirstEqualRow | CurrentGraphCrossActivityMode.ShowRelationNet | CurrentGraphCrossActivityMode.StopProcess;
			gd.CurrentGraphActivityOnDoubleClick = CurrentGraphCrossActivityMode.FindEqualRow | CurrentGraphCrossActivityMode.ActivateFirstEqualRow | CurrentGraphCrossActivityMode.ActivateGraphPage | CurrentGraphCrossActivityMode.StopProcess;
			args.GraphDeclarationList.Add(gd);

			// Graf plnění poptávek, výroby, polotovarů:
			gd = new GraphDeclarationCls(RowGraphMode.Gantt, PlanUnitSAxisCls.ClassNr, dataSource, tag,
				"Poptávky a polotovary", GraphPositionType.BottomPart);
			gd.DrawLinkMode = LinkElementDrawMode.HighlightActiveLink;
			gd.TargetGraphActivityOnRowEnter = TargetGraphCrossActivityMode.OnThisPage;
			gd.TargetGraphActivityOnDataChanged = TargetGraphCrossActivityMode.Anywhere;
			gd.TargetGraphActivityOnClick = TargetGraphCrossActivityMode.OnThisPage;
			gd.TargetGraphActivityOnDoubleClick = TargetGraphCrossActivityMode.None;
			gd.CurrentGraphActivityOnDataChanged = CurrentGraphCrossActivityMode.DefaultEdit;
			gd.CurrentGraphActivityOnClick = CurrentGraphCrossActivityMode.InactiveWhenInvisible | CurrentGraphCrossActivityMode.FindByDataSource | CurrentGraphCrossActivityMode.SelectElements | CurrentGraphCrossActivityMode.ActivateFirstEqualRow | CurrentGraphCrossActivityMode.SelectParentTopRow | CurrentGraphCrossActivityMode.OpenActiveTreeNodes | CurrentGraphCrossActivityMode.StopProcess;
			gd.CurrentGraphActivityOnDoubleClick = CurrentGraphCrossActivityMode.FindEqualRow | CurrentGraphCrossActivityMode.ActivateFirstEqualRow | CurrentGraphCrossActivityMode.ActivateGraphPage | CurrentGraphCrossActivityMode.StopProcess;
			args.GraphDeclarationList.Add(gd);
			
			args.Priority = 100F;
		}
	}
}
